﻿#region 命名空间

using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using Sharp.Infrastructure;
using Sharp.Infrastructure.Interfaces;

#endregion

namespace Sharp.DataTransferObject
{
    [DebuggerStepThrough()]
    [DataContract, Serializable]
    public partial class PermissionDTO : object, IDTO, ITreeEntity
    {
        public PermissionDTO() { }
        public PermissionDTO(string id, string code, string title, string category, string parentId, int order, string route, string ico = "")
        {
            this.Id = Guid.Parse(id);
            this.Code = code;
            this.Title = title;
            this.Category = category;

            Guid _parentId;
            if (Guid.TryParse(parentId, out _parentId))
            {
                this.ParentId = _parentId;
            }
            else
            {
                this.ParentId = null;
            }
            this.OrderIndex = order;
            this.Route = route;
            this.Ico = ico;
        }
        /// <summary>
        ///     代码
        /// </summary>
        [DataMember()]
        public string Code { get; set; }

        /// <summary>
        ///     标题
        /// </summary>
        /// <value>标题</value>
        [DataMember()]
        public string Title { get; set; }

        /// <summary>
        ///     权限类型
        /// </summary>
        [DataMember()]
        public string Category { get; set; }

        /// <summary>
        ///     程序路由
        /// </summary>
        [DataMember()]
        public string Route { get; set; }


        /// <summary>
        /// 主键
        /// </summary>
        [DataMember()]
        public Guid Id { get; set; }

        /// <summary>
        ///     父id
        /// </summary>
        /// <value>父Id</value>
        [DataMember()]
        public System.Guid? ParentId { get; set; }

        /// <summary>
        ///     排序索引
        /// </summary>
        /// <value>排序的值</value>
        [DataMember()]
        public int OrderIndex { get; set; }
        /// <summary>
        /// 图标
        /// </summary>
        [DataMember()]
        public string Ico { get; set; }

        [DataMember()]
        public string SystemCode { get; set; }
    }
}